package com.yunji.base.service;

import com.yunji.base.bo.MemberQueryBO;
import com.yunji.base.dao.IMemberDao;
import com.yunji.common.model.domain.MemberDO;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Package com.yunji.user.service.impl
 * FileName:	MemberServiceImpl.java
 * Copyright:	Copyright © 2024 云集互联 All Rights Reserved
 * Company:		云集互联
 * @version: 1.0
 * @since: JDK 1.8.0_202
 * Create at:   2024-04-07 02:06:22
 * Description:
 * <p>
 * Modification History:
 * Author					Date					Version         Description
 * -------------------------------------------------------------------------------------
 * HuaAo0803@163.com	2024-04-07 02:06:22     1.0             1.0 Version
 */
@Service
public class MemberService {

    @Resource
    private IMemberDao memberDao;

    public MemberDO selectMember(Long userId) {
        return memberDao.getById(userId);
    }

    public MemberDO selectMember(String phone) {
        return memberDao.searchMember(MemberQueryBO.builder().phone(phone).build());
    }
//
//    public MemberDO selectMember(String openid, String phone) {
//        return memberDao.searchMember(MemberQueryBO.builder().phone(phone).openId(openid).build());
//    }

    public boolean insertMember(MemberDO member) {
        return memberDao.save(member);
    }

    public void updateMember(MemberDO member) {
        Assert.isTrue(memberDao.updateById(member), "个人信息修改失败");
    }

    public List<String> searchTableField(MemberQueryBO param) {
        return memberDao.searchTableField(param);
    }

    public void updateOpenId(String phone,String openId) {
        memberDao.updateOpenId(phone,openId);
    }
}

